 //
//  ViewController.m
//  QZDJcharge
//
//  Created by Rain on 16/6/22.
//  Copyright © 2016年 Rain. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()
@property (weak, nonatomic) IBOutlet UITextField *chargeMoney;
@property (weak, nonatomic) IBOutlet UILabel *realMoney;

@end

@implementation ViewController

- (void)viewDidLoad {
    
    [super viewDidLoad];
    
    self.Knet=[QZDJnet getInstance];
    
    //将KNet的代理与ViewController连接
    self.Knet.delegate=self;
}


- (IBAction)chargeMoneyButton:(id)sender {
    
    NSLog(@"money%@",self.chargeMoney.text);
    [self.Knet getChargeMoneyUseOid:@"1025" andChargeMon:@"300"];
}

#pragma mark - 处理代理方法，接收服务器返回数据
-(void)getChargeMoneyInfoSuccessFeedback:(id)feedbackInfo
{
    //当服务器返回成功数据后，下列代码被激活
    //先解析从服务器传回来的json数据
    NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:feedbackInfo options:NSJSONReadingMutableContainers | NSJSONReadingMutableLeaves error:nil];
    
    //需找需要的json数据
    NSDictionary *data=[dic objectForKey:@"data"];
    
    NSString *realMoneyInfo=[NSString stringWithFormat:@"%@",[data objectForKey:@"acCharge"]];
    
    //在页面显示
    _realMoney.text=realMoneyInfo;

}

-(void)getChargeMoneyInfoFailFeedback:(id)failInfo
{
    NSLog(@"%@",failInfo);
}
    
@end
